<template>
  <el-card class="search-form">
    <template #header>
      <div class="card-header">
        <span>查询条件</span>
      </div>
    </template>
    <el-form :model="searchForm" inline>
      <el-form-item label="用户名">
        <el-input 
          v-model="searchForm.username" 
          placeholder="请输入用户名" 
          clearable 
          @keyup.enter="emitSearch"
        />
      </el-form-item>
      <el-form-item label="真实姓名">
        <el-input 
          v-model="searchForm.realname" 
          placeholder="请输入真实姓名" 
          clearable 
          @keyup.enter="emitSearch"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="emitSearch">查询</el-button>
        <el-button @click="emitReset">重置</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup>
//查询条件(父组件传子组件) 
const props = defineProps({
  searchForm: {
    type: Object,
    required: true
  }
})

//声明查询和重置事件(子组件触发父组件事件)
const emit = defineEmits(['search', 'reset'])

const emitSearch = () => {
  emit('search')
}

const emitReset = () => {
  emit('reset')
}
</script>

<style scoped>
.search-form {
  margin-bottom: 10px;
}
</style>